package com.example.api.controller;

import com.example.api.aspect.SystemControllerLog;
import com.example.api.model.entity.TollRule;
import com.example.api.model.enums.ActionTypeEnum;
import com.example.api.model.support.RespBean;
import com.example.api.service.TollRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "收费规则管理")
@RestController
@RequestMapping("/api/rule")
public class TollRuleController {

    @Resource
    private TollRuleService tollRuleService;

    @ApiOperation("查询收费规则")
    @GetMapping("/")
    @SystemControllerLog(description = "查询收费规则", actionType = ActionTypeEnum.QUERY)
    public List<TollRule> findAll() {
        return tollRuleService.findAll();
    }

    @ApiOperation("更新收费规则")
    @PutMapping("/")
    @SystemControllerLog(description = "更新收费规则", actionType = ActionTypeEnum.UPDATE)
    public RespBean update(@RequestBody TollRule tollRule) {
        return tollRuleService.update(tollRule);
    }

}
